{$header}
<div id="main" class="main" >
    <div class="content">
  <h3 class="heading">销售订单号<strong>{$_REQUEST.id|getModelName='Order','mano'}</strong> 产品 [ <a href="__APP__/Order">返回销售订单列表</a> ] 
<div class="btn-group pull-right">
	<button class="btn btn-primary" onclick="selProduct({$_REQUEST.id})"><i class="icon-search icon-white"></i> 选择产品</button>
	<button class="btn btn-primary" onclick="addProduct({$_REQUEST.id})"><i class="icon-tags icon-white"></i> 创建产品</button>
</div>
  </h3>
<div id="result" class="result none"></div>
<ul id="myTab" class="nav nav-tabs">
	<li><a href="__URL__/edit/id/{$_REQUEST.id}">订单概要</a></li>
	<li  class="active"><a href="#plist" data-toggle="tab">产品信息</a></li>
</ul>
<php>
	function getBuyId($orderdetail_id){
	$buyid = M('Buy')->where('order_detail_id = '.$orderdetail_id)->getField('id');
	return $buyid;
}
	function getCountA($pid){
	return M('Ask_supplier_detail')->where('product_id ='.$pid)->count('id');
}
</php>
 <div id="myTabContent" class="tab-content">
            
	<div class="tab-pane fade in active" id="plist">
		<table class="table table-bordered table-striped">
			<tr><th>小订单号</th><th>产品中文</th><th>英文名称</th><th>CAS</th><th>备注</th><th>数量</th><th>单位</th><th>单价</th><th>小计</th><th>运费</th><th>总计</th> <th>规格</th><th>要求交货期</th><th>优先级</th> <th>付款货币</th> 
			<th>成本</th> <th>预收款</th><th>余款</th><th>应收款</th><th>已收预付款</th><th>已收余款</th><th>实际收款</th>
			<th>备注</th><th>状态</th><th>库存</th><th>采购订单</th><th>询价历史</th>  <th>编辑</th><th>删除</th> </tr>
			<volist name="products" id="ca">
				<tr>
				<td>{$ca.dmano}</td>
				<td>{$ca.name}</td>
				<td>{$ca.ename}</td>
				<td>{$ca.cas} <img src="__PUBLIC__/Uploads/product/{$ca.cas}.jpg"> </td>
				<td>{$ca.did|getMsgTip}</td>
				<td>{$ca.number}</td>
				<td>{$ca.unit_id|getModelName='Unit'}</td>
				<td>{$ca.price}</td>
				<td>{$ca.dtotal}</td>
				<td>{$ca.dlogifee}</td>
				<td>{:$ca['dtotal'] + $ca['dlogifee']}</td><!--总计-->
				<td>{$ca.specification|getModelName='Specification'}</td>
				<td>{$ca.delivery_date|toDate='Y-m-d'}</td>
				<td>{$ca.priority|getConfigVal='priority'}</td>
				<td>{$ca.currency|getConfigVal='currency'}</td>
				<td>{$ca.dcost}</td>
				
				<td>{$ca.dto_first_pay}</td>
				<td>{$ca.dto_remain_pay}</td>
				<td>{$ca.dshould_pay}</td><!--应收款-->
				<td>{$ca.dfirst_pay}</td>
				<td>{$ca.dremain_pay}</td>
				<td>{$ca.dreal_pay}</td>
				<td>{$ca.dremark}</td>
				<td>{$ca.dstatus|getConfigVal='orderDetailStatus'}</td>
				<td>{$ca.pid|getStock=$ca['specification']}</td>
				<php>$buyid = getBuyId($ca['did']);</php>
				<td><a href="__APP__/Buy/edit/id/{$ca.did|getBuyId}">{$buyid|getModelName='Buy','mano'}</a></td>
				
				<td><a href="#" onClick="window.open('__APP__/Product/asksup/id/{$ca.pid}','','height=600,width=700,scrollbars=yes,status =yes')">询价({$ca.pid|getCountA})</a> </td>

				<td><a href="__APP__/Order_detail/edit/id/{$ca.did}">编辑</a> </td>
				<td><a href="__APP__/Order_detail/foreverdelete/id/{$ca.did}">删除</a> </td>
			</tr>
			</volist>
		</table>
		<div class="page">{$page}</div>
	</div><!--profile-->

</div>
</div>
<include file="Public:footer" />
<load href="__PUBLIC__/Js/jquery-1.7.2.min.js"/>
<load href="__PUBLIC__/bootstrap/js/bootstrap-tab.js" />
<script type="text/javascript">
	function selProduct(id){
		if(id)
			 window.open(APP+'/Product/search?form=form1&supplier_id='+id,'selected','directorys=no,toolbar=no,status=no,menubar=no,resizable=yes,width=1000,height=800,top=100,left=120,scrollbars=yes');
		else
			alert("请选择供应商");
			return false;
	}

function addProduct(id){
		if(id)
			 location.href = APP+'/Product/add/supplier_id/'+id;
		else
			alert("请选择供应商");
			return false;
	}
</script>
